package com.weic.controller;

import com.weic.pojo.User;
import com.weic.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ParameterController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/getDataPage")
    public String getDataPage(HttpServletRequest request, HttpSession session, Model model){
        List<User> users = userService.findAllUser();
        request.setAttribute("message","reqMessage");
        request.setAttribute("users",users);
        model.addAttribute("msg","modelMessage");

        session.setAttribute("message","sessionMsg");
        session.setAttribute("users",users);

        ServletContext application = request.getServletContext();
        application.setAttribute("message","applicationMsg");
        application.setAttribute("users",users);
        return "redirect:/parameter/recirectPage";
    }
}
